﻿namespace PillBox.Client.Framework
{
    using System.ComponentModel.Composition;
    using System.ComponentModel.Composition.Hosting;
    using System.Reflection;
    using System.Windows;

    public static class IoC
    {
        private static CompositionContainer _compositionContainer;

        public static void Initialize()
        {
			_compositionContainer = new CompositionContainer(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
			CompositionHost.Initialize(_compositionContainer);
        }

        public static T GetInstance<T>()
        {
            return _compositionContainer.GetExportedValue<T>();
        }

        public static void RegisterInstance<T>(T exportedValue)
        {
            _compositionContainer.ComposeExportedValue<T>(exportedValue);
        }
    }
}